$(function () {
    $('.am-header-title').text('预约');

    var type=$('#type').val();
    if (type==1){
        $('#sp').removeAttr("hidden");
    }

});

function appointment(){
    var url="/dsmdDesigner/designerAppointment";

    var name=$('#name').val();
    var address=$('#address').val();
    var phone=$('#phone').val();
    var email=$('#email').val();
    var age=$('#age').val();
    var profession=$('#profession').val();
    var sex=$('#sex').val();
    var high=$('#high').val();
    var weight=$('#weight').val();
    var chest=$('#chest').val();
    var waistline=$('#waistline').val();
    var buttocks=$('#buttocks').val();
    var arm=$('#arm').val();
    var trousers=$('#trousers').val();
    var shoulder=$('#shoulder').val();
    var neck=$('#neck').val();
    var special=$('#special').val();
    var designerId=$('#designerId').val();

    if($('#name').val()==''){
        alert($('#name').attr('placeholder'));
        return false;
    }
    if($('#address').val()==''){
        alert($('#address').attr('placeholder'));
        return false;
    }
    if($('#phone').val()==''){
        alert($('#phone').attr('placeholder'));
        return false;
    }
    if($('#email').val()==''){
        alert($('#email').attr('placeholder'));
        return false;
    }
    if($('#age').val()==''){
        alert($('#age').attr('placeholder'));
        return false;
    }
    if($('#profession').val()==''){
        alert($('#profession').attr('placeholder'));
        return false;
    }
    if($('#sex').val()==''){
        alert($('#sex').attr('placeholder'));
        return false;
    }
    if (type==1) {
        // if ($('#high').val() == '') {
        //     alert($('#high').attr('placeholder'));
        //     return false;
        // }
        // if ($('#weight').val() == '') {
        //     alert($('#weight').attr('placeholder'));
        //     return false;
        // }
        // if ($('#chest').val() == '') {
        //     alert($('#chest').attr('placeholder'));
        //     return false;
        // }
        // if ($('#waistline').val() == '') {
        //     alert($('#waistline').attr('placeholder'));
        //     return false;
        // }
        // if ($('#buttocks').val() == '') {
        //     alert($('#buttocks').attr('placeholder'));
        //     return false;
        // }
        // if ($('#arm').val() == '') {
        //     alert($('#arm').attr('placeholder'));
        //     return false;
        // }
        // if ($('#trousers').val() == '') {
        //     alert($('#trousers').attr('placeholder'));
        //     return false;
        // }
        // if ($('#shoulder').val() == '') {
        //     alert($('#shoulder').attr('placeholder'));
        //     return false;
        // }
        // if ($('#neck').val() == '') {
        //     alert($('#neck').attr('placeholder'));
        //     return false;
        // }
    }
    if($('#special').val()==''){
        alert($('#special').attr('placeholder'));
        return false;
    }
    if($('#designerId').val()==''){
        alert($('#designerId').attr('placeholder'));
        return false;
    }


    //if (name == "" || address=="" || phone=="" || email=="" || age=="" || profession=="" || sex=="" || special=="" ) {
    //    alert("请将信息补充完整");
    //    return false;
    //}
    //var phoneReg1='^1[3|4|5|7|8][0-9]\\d{8}$';
    //if(!phoneReg1.test(phone)){
    //    alert("电话号码格式不正确");
    //    return false;
    //}
    //var emailReg='("^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$")';
    //if(!emailReg.test(email)){
    //    alert("email格式不正确");
    //    return false;
    //}

    var type=$('#type').val();
    if (type==1) {
        if (weight == "" || chest == "" || waistline == "" || buttocks == "" || arm == "" || trousers == "" || shoulder == "" || neck == "") {
            alert("请将信息补充完整");
            return false;
        }
    }

    $.ajax({
        type:"post",
        url:url,
        data:{
            name:name,
            address:address,
            phone:phone,
            email:email,
            age:age,
            profession:profession,
            sex:sex,
            high:high,
            weight:weight,
            chest:chest,
            waistline:waistline,
            buttocks:buttocks,
            arm:arm,
            trousers:trousers,
            shoulder:shoulder,
            neck:neck,
            special:special,
            designerId:designerId
        },
        success:function(result){
            if (result.code == "000000") {
                alert("预约成功")
                location.href="dsmd-detail.jsp?id="+designerId+"&type="+type;
            }
        },
        error:function(result){
            alert("???")
        }
    });
}